
import { CommonUtil } from "../../../util/common-util";
import { ShapeBox } from "./component-related/shape-box-interface";
import { BoxStyle } from "./component-related/box-style-model";
import { PointStyle } from "../point-model/point-related/point-style";
import { PointInterface } from "../point-model/point-related/point-interface";
import { ShapeBoxBase } from "./component-related/box-base";

export class RectBox extends ShapeBoxBase implements ShapeBox {
    id: string;
    style: BoxStyle;
    ctx: CanvasRenderingContext2D;
    paint() {
        super.paint();

        let width = this.getWidth();
        let height = this.getHeight();

        let keyPoints = [{
            left: width / 2, top: height / 2
        }, {
            left: (width - this.style.rwidth) / 2, top: (height - this.style.rheight) / 2
        }]
        this.setCanvasPadding(keyPoints);

        let ctx: CanvasRenderingContext2D = this.ctx;
        ctx.lineWidth = this.style.lineWidth;
        ctx.fillStyle = this.style.bgColor;
        ctx.strokeStyle = this.style.color;
        ctx.beginPath();
        ctx.rect(keyPoints[1].left, keyPoints[1].top, this.style.rwidth, this.style.rheight);
        ctx.closePath();
        ctx.fill();
        ctx.stroke();
    }
    constructor(data) {
        super(data);
    }
}